#!/bin/bash

#本脚本用于armbian系统安装宝塔面板,宝塔面板版本为7.5.1
#已经在斐逊N1的armbain5.77上测试成功,其他设备未测试,谨慎使用!

#脚本包含三部分
# 1) 更新国内软件源,使用中科大的源
# 2) 源码编译安装libiconv库,库文件来自南京大学开源镜像站
# 3) 安装宝塔面板,来自宝塔官方


#更新国内源
cd /etc/apt/
mv sources.list sources.list.bak
wget https://gitee.com/ryuukarin/shell_scripts/raw/master/sources.list
chmod 755 sources.list
echo "sources.list Updating ..."
apt update


#安装libiconv库
echo "Ready to install libiconv dependency package..."
mkdir /root/software && cd /root/software
wget http://mirrors.nju.edu.cn/gnu/libiconv/libiconv-1.16.tar.gz
if [ -f libiconv-1.16.tar.gz ];then
    tar zxvf libiconv-1.16.tar.gz
    cd /root/software/libiconv-1.16
    ./configure --prefix=/usr/local
    if [ $? -eq 0 ];then
        make && make install
        if [ $? -eq 0 ];then
            echo "libiconv dependency package Installation successful"
        else
            echo "libiconv dependency package Installation failed";exit 1
        fi
    else
        echo "Libiconv dependency package configuration failed";exit 1
    fi
else
    echo "Libiconv dependency package download failed";exit 1
fi

ln -s /usr/local/lib/libiconv.so /usr/lib
ln -s /usr/local/lib/libiconv.so.2 /usr/lib/libiconv.so.2
cd /root
rm -rf /root/software/


#下载宝塔安装脚本并执行(宝塔版本7.5.1)
mkdir /root/bt && cd /root/bt/
echo "Preparing to install the BT panel..."
wget -O install.sh http://download.bt.cn/install/install-ubuntu_6.0.sh && bash install.sh
